package com.zhx.common.chat.service.strategy.mark;

import com.zhx.common.common.exception.CommonErrorEnum;
import com.zhx.common.common.util.AssertUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 消息标记策略工厂
 */
public class MsgMarkStrategyFactory {
    private static final Map<Integer,AbstractMsgMarkStrategy> STRATEGY_MAP = new HashMap<>();

    public static void register(Integer markType,AbstractMsgMarkStrategy strategy){
        STRATEGY_MAP.put(markType,strategy);
    }

    public static AbstractMsgMarkStrategy getStrategyNoNull(Integer markType){
        AbstractMsgMarkStrategy strategy = STRATEGY_MAP.get(markType);
        AssertUtil.isNotEmpty(strategy, CommonErrorEnum.PARAM_INVALID);
        return strategy;
    }
}
